package com.app.xinfadi.ui.home.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.app.xinfadi.R;
import com.app.xinfadi.dao_bean.bean.CommodityCategoryBean;
import com.app.xinfadi.dao_bean.bean.PlantingSiteBean;

import java.util.ArrayList;
import java.util.List;

/**
 * function:
 * Created by Wutengfei on 2016/1/27.
 */
public class PlantingSiteDropPoplistAdapter  extends BaseAdapter {
    private Context context;
    private List<PlantingSiteBean> datas;

    public PlantingSiteDropPoplistAdapter(Context context) {
        this.context = context;
        this.datas = new ArrayList<PlantingSiteBean>();
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int arg0) {
        return datas.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.dropdownlist_popupwindow_list_item, null);
            holder = new ViewHolder();
            holder.nameTv = (TextView) convertView
                    .findViewById(R.id.nameTv);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.nameTv.setText(datas.get(position).NAME);
        return convertView;
    }

    class ViewHolder {
        TextView nameTv;
    }

    public List<PlantingSiteBean> getDatas() {
        return datas;
    }

    public void setDatas(List<PlantingSiteBean> datas) {
        this.datas = datas;
    }
}
